﻿using System;
using System.Data;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Configuration;
using System.Globalization;
using Telerik.Web.UI;
using KPIS.GERP.GHRMS.BLL;
using KPIS.GERP.GHRMS.IBLL;
using KPIS.GERP.GHRMS.MODEL;
using KPIS.GERP.GHRMS.APP.Classes;
using _WebShared.Classes;

namespace KPIS.GERP.GHRMS.APP.App_UI.UserControls
{
    public partial class PS_EmployeeParentEdit : System.Web.UI.UserControl
    {
        private SsMng ssMng = new SsMng();
        private object _dataItem = null;
        //I_HRM_MP_Jobsites job = new B_HRM_MP_Jobsites();
        //I_HRM_MP_WorkAreas area = new B_HRM_MP_WorkAreas();
        //I_HRM_MP_JobsiteLevels lv = new B_HRM_MP_JobsiteLevels();
        //I_HRM_MP_JobsiteCommands cmd = new B_HRM_MP_JobsiteCommands();
        //I_MAS_Nationalities nat = new B_MAS_Nationalities();
        //I_MAS_Districts dis = new B_MAS_Districts();
        //I_HRM_PS_EmployeeParents parent = new B_HRM_PS_EmployeeParents();
        IMasNamePrefixBLL prefixBLL = new MasNamePrefixBLL();
        Main main = new Main();

        protected void Page_Load(object sender, EventArgs e)
        {
            LoadDDLParentType();
            LoadDDLNamePrefixSeq();

            if (DataItem != null)
            {
                if (!(DataItem is Telerik.Web.UI.GridInsertionObject))
                {
                    ddlParentType.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "parent_type"));
                    ddlNamePrefixSeq.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "name_prefix_seq"));
                    rblCareStatus.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "care_status"));
                    rblParentStatus.SelectedValue = Convert.ToString(DataBinder.Eval(DataItem, "parent_status"));
                }
                else
                {
                    lblMode.Text = "เพิ่มข้อมูลใหม่";
                    imgMode.ImageUrl = "~/App_UI/Images/Buttons/saveDisk.gif";
                }
            }
        }

        public object DataItem
        {
            get
            {
                return this._dataItem;
            }
            set
            {
                this._dataItem = value;
            }
        }

        protected void LoadDDLParentType()
        {
            //ddlParentType.DataSource = parent.SelectParentType();
        }

        protected void LoadDDLNamePrefixSeq()
        {
            IList<MasNamePrefixInfo> infoList = prefixBLL.ListNamePrefixes();

            ddlNamePrefixSeq.DataSource = infoList;
            ddlNamePrefixSeq.DataBind();
        }

        //============================= ControlEvents ======================================

        protected void cmdAdd_Click(object sender, EventArgs e)
        {
            string strParentType = ddlParentType.SelectedValue;
            string strNamePrefixSeq = ddlNamePrefixSeq.SelectedValue;
            string strParentName = txtParentName.Text;
            string strParentLastName = txtParentLastName.Text;
            string strCareStatus = rblCareStatus.SelectedValue;
            string strParentStatus = rblParentStatus.SelectedValue;

            //parent.Insert(ssMng.EmpSeq, strNamePrefixSeq, strParentName, strParentLastName
            //    , strParentType, strCareStatus, strParentStatus
            //    , "U", Session["UserID"].ToString(), DateTime.Now);
        }

        protected void cmdUpdate_Click(object sender, EventArgs e)
        {
            string strParentSeq = lblParentSeq.Text;
            string strParentType = ddlParentType.SelectedValue;
            string strNamePrefixSeq = ddlNamePrefixSeq.SelectedValue;
            string strParentName = txtParentName.Text;
            string strParentLastName = txtParentLastName.Text;
            string strCareStatus = rblCareStatus.SelectedValue;
            string strParentStatus = rblParentStatus.SelectedValue;

            //parent.Update(strParentSeq, ssMng.EmpSeq
            //    , strNamePrefixSeq, strParentName, strParentLastName
            //    , strParentType, strCareStatus, strParentStatus
            //    , Session["UserID"].ToString(), DateTime.Now);
        }
    }
}